﻿using System;
using System.Diagnostics;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                while (true)
                {
                    Run();
                    Console.ResetColor();
                }
            }
            catch (Exception ex)
            {
                Console.BackgroundColor = ConsoleColor.Red;
                Console.WriteLine(ex.Message);
                Console.BackgroundColor = ConsoleColor.White;
                Console.ResetColor();
                Run();
            }
        }

        public static void Run()
        {
            Console.Title = "Agile 控制台程序 ";
            Console.WriteLine("从下列列表中选择一个选项:");
            Console.WriteLine("\t1 - 根据实体类生成数据库表");
            Console.WriteLine("\t2 - 根据数据库表生成测试数据");
            Console.WriteLine("\t3 - 根据视图文件(cshtml)添加页面命令数据");

            Console.Write("Your option? ");
            Stopwatch _sw = new Stopwatch();
            _sw.Start();
          
            switch (Console.ReadLine())
            {
                case "1":
                    CreateTableServics.Run();
                    break;
                case "2":
                    DbTestDataGenerate.Run();
                    break;
                case "3":
                    HrCollectionPageButtons.Run();
                    break;
                default:
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("\n从下列列表中没有找到选项\n");
                    Console.ForegroundColor = ConsoleColor.White;
                    break;
            }

            _sw.Stop();
            TimeSpan ts2 = _sw.Elapsed;
            int seconds = Utils.GetObjTranNull<int>(ts2.TotalSeconds % 60);
            int minutes = Utils.GetObjTranNull<int>((ts2.TotalSeconds / 60) % 60);
            int hours = Utils.GetObjTranNull<int>(ts2.TotalSeconds / 3600);
            Console.ResetColor();
            Console.WriteLine("\n总共花费=" + string.Format("{0}:{1}:{2}", hours, minutes, seconds) + "\n");
            Console.WriteLine(" ");
        }
    }
}
